/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.i0o.appliancemanager.ui.window;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
import org.i0o.appliancemanager.helper.UIHelper;
import org.i0o.appliancemanager.helper.Utilities;
import org.i0o.utilplus.StringUtil;

/**
 *
 * @author Administrator
 */
public class PosWin extends BaseWin {

    /**
     * Creates new form PosWin
     */
    public PosWin() {
        initComponents();
    }

    @Override
    protected void initialize() {
        String currentDate = StringUtil.getCurrentDate();
        this.lblLoginTime.setText(currentDate);
    }

    @Override
    protected void initStyle() {
        int blodFont = Font.BOLD;
        int titleFontSize = 20;
        int currentReceiptsFontSize = 14;
        int currentCountFontSize = 40;

        UIHelper.setFont(this.lblDatetime, blodFont, titleFontSize);
        UIHelper.setFont(this.lblTitle, blodFont, titleFontSize);
        UIHelper.setFont(this.lblCount, blodFont, currentReceiptsFontSize);
        UIHelper.setFont(this.lblAmount, blodFont, currentReceiptsFontSize);
        UIHelper.setFont(this.lblCountTxt, blodFont, currentReceiptsFontSize);
        UIHelper.setFont(this.lblAmountTxt, blodFont, currentCountFontSize);

        UIHelper.setFont(this.txtInput, blodFont, 40);
        UIHelper.setFont(this.lblHelper, blodFont, 25);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        GridBagConstraints gridBagConstraints;
        JPanel panBG = new JPanel();
        JPanel panTop = new JPanel();
        lblTitle = new JLabel();
        lblDatetime = new JLabel();
        JScrollPane jScrollPane1 = new JScrollPane();
        mainTable = new JTable();
        JPanel panInfoLeft = new JPanel();
        JPanel jPanel1 = new JPanel();
        JLabel jLabel1 = new JLabel();
        JLabel jLabel2 = new JLabel();
        JLabel jLabel3 = new JLabel();
        lblUserTxt = new JLabel();
        JLabel lblLoginDatetime = new JLabel();
        JLabel lblLoginDateTimeTxt = new JLabel();
        JLabel jLabel7 = new JLabel();
        JLabel jLabel8 = new JLabel();
        JLabel jLabel9 = new JLabel();
        JLabel jLabel10 = new JLabel();
        JLabel jLabel11 = new JLabel();
        JLabel jLabel12 = new JLabel();
        JLabel jLabel13 = new JLabel();
        lblGroupTxt = new JLabel();
        JLabel jLabel15 = new JLabel();
        loginDuration = new JLabel();
        lblLoginTime = new JLabel();
        lblHelper = new JLabel();
        txtInput = new JTextField();
        JPanel panInfoRight = new JPanel();
        JPanel jPanel5 = new JPanel();
        JPanel jPanel6 = new JPanel();
        lblAmount = new JLabel();
        lblAmountTxt = new JLabel();
        lblCount = new JLabel();
        lblCountTxt = new JLabel();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setBackground(Color.black);
        setMinimumSize(new Dimension(800, 600));
        setPreferredSize(new Dimension(800, 600));

        panTop.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        panTop.setOpaque(false);

        lblTitle.setText(Utilities.getString("posDefaultTitle")); // NOI18N

        lblDatetime.setText(Utilities.getString("posDefaultDatetime")); // NOI18N

        GroupLayout panTopLayout = new GroupLayout(panTop);
        panTop.setLayout(panTopLayout);
        panTopLayout.setHorizontalGroup(
            panTopLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(panTopLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTitle, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(lblDatetime, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panTopLayout.setVerticalGroup(
            panTopLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(lblTitle, GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
            .addComponent(lblDatetime, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        mainTable.setModel(new DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "编号", "品名", "数量", "单位", "价格"
            }
        ) {
            Class[] types = new Class [] {
                Long.class, String.class, Integer.class, String.class, Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(mainTable);
        mainTable.getColumnModel().getColumn(0).setResizable(false);
        mainTable.getColumnModel().getColumn(0).setPreferredWidth(100);
        mainTable.getColumnModel().getColumn(0).setHeaderValue(Utilities.getString("posTableNumber")); // NOI18N
        mainTable.getColumnModel().getColumn(1).setPreferredWidth(250);
        mainTable.getColumnModel().getColumn(1).setHeaderValue(Utilities.getString("posTableCommodityName")); // NOI18N
        mainTable.getColumnModel().getColumn(2).setResizable(false);
        mainTable.getColumnModel().getColumn(2).setPreferredWidth(40);
        mainTable.getColumnModel().getColumn(2).setHeaderValue(Utilities.getString("posTableCount")); // NOI18N
        mainTable.getColumnModel().getColumn(3).setResizable(false);
        mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
        mainTable.getColumnModel().getColumn(3).setHeaderValue(Utilities.getString("posTableUnit")); // NOI18N
        mainTable.getColumnModel().getColumn(4).setResizable(false);
        mainTable.getColumnModel().getColumn(4).setPreferredWidth(80);
        mainTable.getColumnModel().getColumn(4).setHeaderValue(Utilities.getString("posTablePrice")); // NOI18N

        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        GridBagLayout jPanel1Layout = new GridBagLayout();
        jPanel1Layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0};
        jPanel1Layout.rowHeights = new int[] {0, 10, 0, 10, 0, 10, 0};
        jPanel1.setLayout(jPanel1Layout);

        jLabel1.setText(Utilities.getString("posListNum")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel1, gridBagConstraints);

        jLabel2.setText("jLabel2");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(jLabel2, gridBagConstraints);

        jLabel3.setText(Utilities.getString("posUser")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel3, gridBagConstraints);

        lblUserTxt.setText("jLabel4");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(lblUserTxt, gridBagConstraints);

        lblLoginDatetime.setText(Utilities.getString("posLoginDateTime")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(lblLoginDatetime, gridBagConstraints);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(lblLoginDateTimeTxt, gridBagConstraints);

        jLabel7.setText(Utilities.getString("posMumber")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel7, gridBagConstraints);

        jLabel8.setText(Utilities.getString("publicNull")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(jLabel8, gridBagConstraints);

        jLabel9.setText(Utilities.getString("posIntegral")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel9, gridBagConstraints);

        jLabel10.setText(Utilities.getString("publicNull")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(jLabel10, gridBagConstraints);

        jLabel11.setText(Utilities.getString("posInCome")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel11, gridBagConstraints);

        jLabel12.setText("jLabel12");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(jLabel12, gridBagConstraints);

        jLabel13.setText(Utilities.getString("posGroup")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel13, gridBagConstraints);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(lblGroupTxt, gridBagConstraints);

        jLabel15.setText(Utilities.getString("posLoginLongTime")); // NOI18N
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanel1.add(jLabel15, gridBagConstraints);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(loginDuration, gridBagConstraints);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        jPanel1.add(lblLoginTime, gridBagConstraints);

        lblHelper.setBorder(BorderFactory.createEtchedBorder());

        txtInput.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent evt) {
                txtInputKeyPressed(evt);
            }
        });

        GroupLayout panInfoLeftLayout = new GroupLayout(panInfoLeft);
        panInfoLeft.setLayout(panInfoLeftLayout);
        panInfoLeftLayout.setHorizontalGroup(
            panInfoLeftLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
            .addGroup(panInfoLeftLayout.createSequentialGroup()
                .addComponent(lblHelper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(txtInput, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE))
        );
        panInfoLeftLayout.setVerticalGroup(
            panInfoLeftLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(panInfoLeftLayout.createSequentialGroup()
                .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addGroup(panInfoLeftLayout.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(txtInput, GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                    .addComponent(lblHelper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jPanel5.setBorder(BorderFactory.createEtchedBorder());

        GroupLayout jPanel5Layout = new GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 296, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 87, Short.MAX_VALUE)
        );

        jPanel6.setBorder(BorderFactory.createEtchedBorder());

        lblAmount.setText(Utilities.getString("posAmount")); // NOI18N

        lblAmountTxt.setText(Utilities.getString("posDefAmount")); // NOI18N

        lblCount.setText(Utilities.getString("posCount")); // NOI18N

        lblCountTxt.setText(Utilities.getString("posDefCount")); // NOI18N

        GroupLayout jPanel6Layout = new GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(lblAmount)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(lblCount)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(lblCountTxt, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(lblAmountTxt, GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblAmount)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(lblAmountTxt, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(lblCountTxt, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCount))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        GroupLayout panInfoRightLayout = new GroupLayout(panInfoRight);
        panInfoRight.setLayout(panInfoRightLayout);
        panInfoRightLayout.setHorizontalGroup(
            panInfoRightLayout.createParallelGroup(Alignment.LEADING)
            .addComponent(jPanel5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panInfoRightLayout.setVerticalGroup(
            panInfoRightLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(panInfoRightLayout.createSequentialGroup()
                .addComponent(jPanel5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jPanel6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        GroupLayout panBGLayout = new GroupLayout(panBG);
        panBG.setLayout(panBGLayout);
        panBGLayout.setHorizontalGroup(
            panBGLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(panBGLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addGroup(panBGLayout.createParallelGroup(Alignment.TRAILING)
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 992, Short.MAX_VALUE)
                    .addComponent(panTop, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(panBGLayout.createSequentialGroup()
                        .addComponent(panInfoLeft, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(panInfoRight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                .addGap(5, 5, 5))
        );
        panBGLayout.setVerticalGroup(
            panBGLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(panBGLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(panTop, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                .addGap(5, 5, 5)
                .addGroup(panBGLayout.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(panInfoRight, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panInfoLeft, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(5, 5, 5))
        );

        getContentPane().add(panBG, BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtInputKeyPressed(KeyEvent evt) {//GEN-FIRST:event_txtInputKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtInputKeyPressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    JLabel lblAmount;
    JLabel lblAmountTxt;
    JLabel lblCount;
    JLabel lblCountTxt;
    JLabel lblDatetime;
    JLabel lblGroupTxt;
    JLabel lblHelper;
    JLabel lblLoginTime;
    JLabel lblTitle;
    JLabel lblUserTxt;
    JLabel loginDuration;
    JTable mainTable;
    JTextField txtInput;
    // End of variables declaration//GEN-END:variables
}
